<template>
	<view class="selectionMethod" :class="APPTheme">
		<uni-nav-bar fixed status-bar title="选择方式" :color="APPTheme=='theme-light'?'#000000':'#ffffff'" :background-color="APPTheme=='theme-light'?'#ffffff':'#000000'"></uni-nav-bar>
		<uni-list class="uni-list">
			<uni-list-item v-for="(item,index) in list" :key="index" :show-extra-icon="true" :extra-icon="item.extraIcon" class="uni-list-item theme-bg theme-bg-active" :title="item.title" note="" @click="navigateToFn(item)"></uni-list-item>
		</uni-list>
	</view>	
</template>

<script>
	let that
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	export default {
		components:{},
		data() {
			return {
				option:{
					type:'',//选择类型如收件人，抄送人
					employeesList:[],//已选择人
					departmentsList:[]//已选择的组织
				},
				list:[{
					title:'从组织中选取',
					extraIcon:{
						color: '#4cd964',size: '22',type: 'flag'
					}
					
				},
				{
					title:'从角色中选取',
					extraIcon:{
						color: '#4cd964',size: '22',type: 'person'
					}
				},
				
				]
				
			}
		},
		computed: {
			...mapGetters(['APPTheme', 'userInfo', 'api']),
		},
		onLoad(e) {
			that = this
			console.log(e);
			if(e.data){
				that.option={
					type:e.title,//选择类型如收件人，抄送人
					employeesList:JSON.parse(e.data).employeesList,//已选择人
					departmentsList:JSON.parse(e.data).departmentsList,//已选择的组织
					roleList:JSON.parse(e.data).roleList,//已选择的角色
				}
			}
		},
		onShow() {
			//设置主题颜色
			that.GLOBAL.setThemeColor(that.APPTheme)
		},
		methods: {
			//添加人员
			navigateToFn(item){
				console.log(item.title)
				if(item.title=='从组织中选取'){
					uni.redirectTo({url: '../mailList/mailList?title='+that.option.type+'&data='+JSON.stringify(that.option)});
				}else{
					uni.redirectTo({url: '../roleMailList/roleMailList?title='+that.option.type+'&data='+JSON.stringify(that.option)});
				}
			},
		}
	};
</script>

<style scoped lang="scss">
	.selectionMethod{
		height: 100%;
		.uni-list-item{
			padding: 0 15px;
		}
	}
</style>
